//
//  ReceiverChooseViewController.m
//  Utils
//
//  Created by enghou on 2018/6/12.
//  Copyright © 2018年 xyxorigation. All rights reserved.
//

#import "ReceiverChooseViewController.h"
#import "SlidePageView.h"
#import "InStationContactViewController.h"
#import "MyGroupViewController.h"
#import "LevelClassViewController.h"
@interface ReceiverChooseViewController ()

@end

@implementation ReceiverChooseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIBarButtonItem *sureBtn = [[UIBarButtonItem alloc]initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(submitAction)];
    self.navigationItem.rightBarButtonItem = sureBtn;
    // Do any additional setup after loading the view.
}

-(void)submitAction{
    NSArray *selectedContacts = [self.ctlArray[0] performSelector:@selector(selectedContacts)];
    NSArray *selectedGroups = [self.ctlArray[1] performSelector:@selector(selectedGroups)];
    NSArray *selectedLevels = [self.ctlArray[2] performSelector:@selector(selectedLevels)];
    if (selectedContacts.count == 0 && selectedGroups.count == 0 && selectedLevels.count == 0) {
        [self alertSome:@"请至少选择一个收件人!"];
        return;
    }
    if ([self.theDelete respondsToSelector:@selector(fetchArray:)]) {
        [self.theDelete fetchArray:@[selectedContacts,selectedGroups,selectedLevels]];
    }
    [self pop];
}

-(void)configViewControllers{
    [self.slide configTitles:@[@"站内负责人",@"我的群组",@"层级"]];
    
    InStationContactViewController *inContact = [[InStationContactViewController alloc]init];
    inContact.contacts = self.selectedContacts;
    [self.ctlArray addObject:inContact];
    MyGroupViewController *group = [[MyGroupViewController alloc]init];
    group.groups = self.selectedGroups;
    [self.ctlArray addObject:group];
    LevelClassViewController *levelClass = [[LevelClassViewController alloc]init];
    levelClass.levels = self.selectedLevels;
    [self.ctlArray addObject:levelClass];
    [self.page setViewControllers:@[self.ctlArray[0]] direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)fetchArray:(NSArray *)array{
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
